<extend name="Public/layout"/>

<block name="body">
    <div class="row">
        <div class="col-xs-12">
            <div class="box flat box-primary">
                <div class="box-body aaaaaa" id="{$boxId}">
                    <div class="dataTables_tool clearfix" style="margin-top: 10px;">
                        <form>
                            <div class="input-group date" style="width: 204px; float: left;">
                                <div class="input-group-addon"><i class="fa fa-calendar"></i></div>
                                <input type="hidden" name="start_time" class="text date"
                                       value="{:I('get.start_time')}"/>
                                <input style="width: auto;" type="text" data-name="start_time"
                                       class="form-control date datepicker" value="{:I('get.start_time')}"
                                       placeholder="请选择开始日期"
                                       data-type="date"/>
                            </div>
                            <div class="input-group date" style="width: 204px; float: left;margin-left: 10px;">
                                <div class="input-group-addon"><i class="fa fa-calendar"></i></div>
                                <input type="hidden" name="end_time" class="text date"
                                       value="{:I('get.end_time')}"/>
                                <input style="width: auto;" type="text" data-name="end_time"
                                       class="form-control date datepicker" value="{:I('get.end_time')}"
                                       placeholder="请选择结束日期"
                                       data-type="date"/>
                            </div>
                            <button style="line-height: 20px;margin-top:auto;margin-left: 10px;" type="submit"
                                    class="btn btn-flat _dt_btns_ btn-default" data-callback="form"
                                    data-param="">
                                搜索
                            </button>
                        </form>
                    </div>

                    <div class="table-wrap">
                        <table id="{$tableId}"
                               class="table table-bordered table-hover table-condensed table-nowrap"
                               data-table-name="{$tableId}">
                            <thead>
                            <tr>
                                <th rowspan="2" style="text-align: center;vertical-align: middle;">日期</th>
                                <th colspan="2" style="text-align: center">购货金额</th>
                                <th colspan="2" style="text-align: center">申购券</th>
                                <th colspan="2" style="text-align: center">已释放申购券</th>
                                <th colspan="2" style="text-align: center">未释放申购券</th>
                                <th colspan="2" style="text-align: center">已释放未使用申购券</th>
                            </tr>
                            <tr>
                                <th style="text-align: center">新增</th>
                                <th style="text-align: center">累计</th>
                                <th style="text-align: center">新增</th>
                                <th style="text-align: center">累计</th>
                                <th style="text-align: center">新增</th>
                                <th style="text-align: center">累计</th>
                                <th style="text-align: center">新增</th>
                                <th style="text-align: center">累计</th>
                                <th style="text-align: center">新增</th>
                                <th style="text-align: center">累计</th>
                            </tr>
                            </thead>
                            <tbody>
                            <foreach name="list" item="row">
                                <tr>
                                    <td style="text-align: center">{$row['date']}</td>
                                    <td style="text-align: center">{$row['import_goods_quota_new']}</td>
                                    <td style="text-align: center">{$row['import_goods_quota_total']}</td>
                                    <td style="text-align: center">{$row['goods_quota_new']}</td>
                                    <td style="text-align: center">{$row['goods_quota_total']}</td>
                                    <td style="text-align: center">{$row['count_new_release']}</td>
                                    <td style="text-align: center">{$row['count_total_release']}</td>
                                    <td style="text-align: center">{$row['count_new_transfer']}</td>
                                    <td style="text-align: center">{$row['count_total_transfer']}</td>
                                    <td style="text-align: center">{$row['count_new_ticket']}</td>
                                    <td style="text-align: center">{$row['count_total_ticket']}</td>
                                </tr>
                            </foreach>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        $(function () {
            $('.form-control.date.datepicker').change(function () {
                $(this).prev().val($(this).val());
            });

            $('.datepicker').each(function () {
                var $this = $(this);
                var dateType = $(this).attr('data-type');
                var handle = "datepicker";
                var format = "yyyy-mm-dd";
                var options = {
                    language: 'zh-CN',
                    autoclose: true,
                    templates: {
                        leftArrow: '<i class="fa fa-caret-square-o-left"></i>',
                        rightArrow: '<i class="fa fa-long-arrow-right"></i>'
                    },
                }
                switch (dateType) {
                    case 'timestamp':
                    case 'datetime':
                        format = "yyyy-mm-dd hh:ii";
                        handle = 'datetimepicker';
                        break;
                    case 'date':
                        format = "yyyy-mm-dd";
                        handle = 'datepicker';
                        break;
                }
                options.format = format;
                var fieldName = $this.attr('data-name');
                $this[handle](options)
                    .on('changeDate,change', function (e) {
                        var value = $(e.currentTarget).val();
                        $('input[name=' + fieldName + ']').val(value);
                    });
            });
        });
    </script>
</block>